<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');



/**

 * This class is for online shop order process - payment.

 * params order step

 * This is the children of controller.

 * PHP5 CMS Typolight

 * Copyright is 34n.sam@gmail.com

 */

 

  /**

 * Start page

 */

session_start();



$thankyou = new ThankyouOthers();

$thankyou->run();



class ThankyouOthers extends Controller

{

	/**

	 * This is class construct function.

	 * @params null

	 * @Return null

	 */

	public function __construct()

	{

		parent::__construct();		

	}

	

	/** 

	 * Start page function

	 * @params null

	 * @Return null

	 */

	public function run()

	{			

		if (!isset($_GET['orderno']) || !$_GET['orderno'])

			return;

		

		echo $this->displayThankyouPage(trim($_GET['orderno']));

	}

	

	/**

	 * Generate the html

	 * @params string

	 * @Return string

	 */

	private function displayThankyouPage($id_order=0)

	{

		if (!$id_order)

			return;

		

		$this->import('FrontendUser', 'User');

		$this->loadDataContainer('tl_member');

		$this->import("Database");

		

		$obj_order = $this->Database->prepare("SELECT * FROM `tl_orders` WHERE `orderno`=?")

									->execute($id_order);

		

		$strHTML = "<h2>Order NO. ". $id_order. "</h2>

		<p>We will send a summary of your order to " . $this->User->email . "</p>

		<p>If you have any questions about your order, please <a href=\"mailto:info@daftshopping.com\" title=\"contact us\"><u>contact us</u></a> or view <a href=\"".$this->Environment->base."order-status.html?mem_id=".$obj_order->id_member."\" title=\"your order status\"><u>your order status</u></a> to get details.</p>

		<!--<p class=\"join\"><a href=\"#\" title=\"JOIN THE GANG ON FACEBOOK\">JOIN THE GANG ON FACEBOOK</a> <a href=\"#\" title=\"JOIN THE GANG ON FACEBOOK\">JOIN THE GANG ON FACEBOOK</a></p>-->";

		

		$total_amout = $obj_order->total_paid_real - $obj_order->total_shipping;
		$obj_currency = $this->Database->prepare("SELECT * FROM tl_currency WHERE iso_code=?")
										->execute('USD');
		$fee_rate = floatval($obj_currency->conversion_rate);
		$total_amout = number_format(floatval($total_amout)*$fee_rate, 2, '.', '');

		$strHTML .= "<!-- Affiliate Offer: Summer Sale + Free Shipping  -->

<iframe src=\"http://tracking.daftshopping.com/aff_l?offer_id=3&amount=" . $total_amout . "\" scrolling=\"no\" frameborder=\"0\" width=\"1\" height=\"1\"></iframe>

<!-- // End Affiliate Offer -->";

		

		return $strHTML;

	}

}